package com.dxq.test.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.R;
import com.dxq.test.db.Label;

import java.util.List;

import cn.ljp.swipemenu.SwipeMenuLayout;

/**
 * Author: zsh
 * Date: 2023/12/03
 * Describe: 牲畜计数adapter
 */
public class InventoryAdapter extends BaseQuickAdapter<Label, BaseViewHolder> {

    public InventoryAdapter(int layoutResId) {
        this(layoutResId, null);
    }

    public InventoryAdapter(int layoutResId, @Nullable List<Label> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, Label item) {
        //holder.setText(R.id.tvSize, String.valueOf(1 + holder.getLayoutPosition()));
        holder.setText(R.id.tvID, item.getID());
        holder.setText(R.id.tvName, item.getName());
        String batteryLevel = item.getBatteryLevel();
        if (batteryLevel.equals(""))
            holder.setText(R.id.tvBatteryLevel, item.getBatteryLevel() + "--");
        else
            holder.setText(R.id.tvBatteryLevel, item.getBatteryLevel() + "%");
        holder.setGone(R.id.tvID, !item.isCheck());
    }
}
